import request from '@/utils/request'
import type { Clue, ClueFollowUp } from '@/types/clue'

export function getClues(params: any) {
  return request.get('/api/clues', { params })
}
export function getClue(id: number) {
  return request.get(`/api/clues/${id}`)
}
export function createClue(data: any) {
  return request.post('/api/clues', data)
}
export function updateClue(id: number, data: any) {
  return request.put(`/api/clues/${id}`, data)
}
export function deleteClue(id: number) {
  return request.delete(`/api/clues/${id}`)
}
export function followupClue(id: number) {
  return request.post(`/api/clues/${id}/followup`)
}
export function assignClue(id: number, ownerId: number) {
  return request.post(`/api/clues/${id}/assign`, { ownerId })
}
export function claimClue(id: number) {
  return request.post(`/api/clues/${id}/claim`)
}
export function recycleClue(id: number) {
  return request.post(`/api/clues/${id}/recycle`)
}
export function convertClue(id: number, data: any) {
  return request.post(`/api/clues/${id}/convert`, data)
}
export function getClueFollowUps(id: number) {
  return request.get(`/api/clues/${id}/followups`)
}
export function addClueFollowUp(id: number, data: any) {
  return request.post(`/api/clues/${id}/followups`, data)
}
export function deleteClueFollowUp(followUpId: number) {
  return request.delete(`/api/clues/followups/${followUpId}`)
}

// 获取未分配的线索
export function getUnassignedClues() {
  return request.get('/api/clues/unassigned')
}

// 获取我的线索
export function getMyClues() {
  return request.get('/api/clues/my')
}
